package com.cq.androidtools.mvp2

import android.os.Bundle
import android.util.Log
import android.widget.Button
import android.widget.EditText
import com.cq.androidtools.R
import com.cq.base.mvp.BaseActivity

/**
 * 作者: CQ
 * 日期: 2021-03-23
 * 说明:
 */
class ViewActivity : BaseActivity<Presenter>(), IView {

    private lateinit var edt1: EditText
    private lateinit var edt2: EditText
    private lateinit var bt: Button
    private lateinit var clear: Button

    override fun getLayoutId(): Int {
        return R.layout.dialog_loading
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        edt1 = findViewById(R.id.name)
        edt2 = findViewById(R.id.pass)
        bt = findViewById(R.id.button)
        clear = findViewById(R.id.clear)
        bt.setOnClickListener {
            presenter.doLogin(edt1.toString(), edt2.toString())
        }
        clear.setOnClickListener {
            presenter.clear()
        }
    }


    override fun showLoadingView() {
        super.showLoadingView()
        Log.e("--", "开始了showLoadingView")
    }

    override fun createPresenter(): Presenter = Presenter()

    override fun onClearText() {
        edt1.setText("")
        edt2.setText("")
    }

    override fun onLoginResult(result: Boolean) {
        showToast("登录成功了")
    }
}